package com.vpen.picupload.entity;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

/**
 * @version: 1.0
 * @author: Vpen
 * @date: 2021/9/5 8:34
 * @content:
 */
@Data
@Accessors(chain = true)
@ApiModel("目标--要存数据库里")
public class BeanResp {
    private Integer age;
    private String name;
    private List<Integer> city;
    private User user;

    public BeanResp covert(DatabaseBean db) {
        List<Integer> city = JSONUtil.toList(db.getCity(), Integer.class);
        User user = JSONUtil.toBean(db.getUser(), User.class);
        BeanUtil.copyProperties(db, this, "city","user");
        return this.setCity(city).setUser(user);
    }


}
